import { defineStore } from "pinia";
import { ref } from "vue";

export const useChatStore = defineStore("chat", {
  state: () => {
    return {
      SDKAppID: 1600094603,
      secretKey:
        "045d5b52d3afe825f7c3b95ab3d654b29d87565ebbcc233ed86d967aa1d0bda5",
      user: ref({}),
      ready: ref(false),
      msgList: ref({}),
      conversationList: ref([]),
    };
  },
  actions: {
    setReady() {
      this.ready = true;
    },
    addMsg(userID, msg) {
      if (!this.msgList[userID]) {
        this.msgList[userID] = [];
      }
      this.msgList[userID].push(msg);
    },
    setUser(user) {
      this.user = user;
    },
  },
});
